/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package InventariosAlmacenes.impl;

import InventariosAlmacenes.Area;
import InventariosAlmacenes.Empleado;
import InventariosAlmacenes.InventariosAlmacenesPackage;
import InventariosAlmacenes.Persona;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Area</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link InventariosAlmacenes.impl.AreaImpl#getId <em>Id</em>}</li>
 *   <li>{@link InventariosAlmacenes.impl.AreaImpl#getNombre <em>Nombre</em>}</li>
 *   <li>{@link InventariosAlmacenes.impl.AreaImpl#getDescripsion <em>Descripsion</em>}</li>
 *   <li>{@link InventariosAlmacenes.impl.AreaImpl#getEReference0 <em>EReference0</em>}</li>
 *   <li>{@link InventariosAlmacenes.impl.AreaImpl#getTiene <em>Tiene</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AreaImpl extends EObjectImpl implements Area {
	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final int ID_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected int id = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getNombre() <em>Nombre</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNombre()
	 * @generated
	 * @ordered
	 */
	protected static final String NOMBRE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getNombre() <em>Nombre</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNombre()
	 * @generated
	 * @ordered
	 */
	protected String nombre = NOMBRE_EDEFAULT;

	/**
	 * The default value of the '{@link #getDescripsion() <em>Descripsion</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescripsion()
	 * @generated
	 * @ordered
	 */
	protected static final String DESCRIPSION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDescripsion() <em>Descripsion</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescripsion()
	 * @generated
	 * @ordered
	 */
	protected String descripsion = DESCRIPSION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getEReference0() <em>EReference0</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEReference0()
	 * @generated
	 * @ordered
	 */
	protected Persona eReference0;

	/**
	 * The cached value of the '{@link #getTiene() <em>Tiene</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTiene()
	 * @generated
	 * @ordered
	 */
	protected EList<Empleado> tiene;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AreaImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return InventariosAlmacenesPackage.Literals.AREA;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(int newId) {
		int oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InventariosAlmacenesPackage.AREA__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getNombre() {
		return nombre;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNombre(String newNombre) {
		String oldNombre = nombre;
		nombre = newNombre;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InventariosAlmacenesPackage.AREA__NOMBRE, oldNombre, nombre));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDescripsion() {
		return descripsion;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescripsion(String newDescripsion) {
		String oldDescripsion = descripsion;
		descripsion = newDescripsion;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InventariosAlmacenesPackage.AREA__DESCRIPSION, oldDescripsion, descripsion));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Persona getEReference0() {
		if (eReference0 != null && eReference0.eIsProxy()) {
			InternalEObject oldEReference0 = (InternalEObject)eReference0;
			eReference0 = (Persona)eResolveProxy(oldEReference0);
			if (eReference0 != oldEReference0) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, InventariosAlmacenesPackage.AREA__EREFERENCE0, oldEReference0, eReference0));
			}
		}
		return eReference0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Persona basicGetEReference0() {
		return eReference0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEReference0(Persona newEReference0) {
		Persona oldEReference0 = eReference0;
		eReference0 = newEReference0;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InventariosAlmacenesPackage.AREA__EREFERENCE0, oldEReference0, eReference0));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Empleado> getTiene() {
		if (tiene == null) {
			tiene = new EObjectContainmentEList<Empleado>(Empleado.class, this, InventariosAlmacenesPackage.AREA__TIENE);
		}
		return tiene;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case InventariosAlmacenesPackage.AREA__TIENE:
				return ((InternalEList<?>)getTiene()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case InventariosAlmacenesPackage.AREA__ID:
				return getId();
			case InventariosAlmacenesPackage.AREA__NOMBRE:
				return getNombre();
			case InventariosAlmacenesPackage.AREA__DESCRIPSION:
				return getDescripsion();
			case InventariosAlmacenesPackage.AREA__EREFERENCE0:
				if (resolve) return getEReference0();
				return basicGetEReference0();
			case InventariosAlmacenesPackage.AREA__TIENE:
				return getTiene();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case InventariosAlmacenesPackage.AREA__ID:
				setId((Integer)newValue);
				return;
			case InventariosAlmacenesPackage.AREA__NOMBRE:
				setNombre((String)newValue);
				return;
			case InventariosAlmacenesPackage.AREA__DESCRIPSION:
				setDescripsion((String)newValue);
				return;
			case InventariosAlmacenesPackage.AREA__EREFERENCE0:
				setEReference0((Persona)newValue);
				return;
			case InventariosAlmacenesPackage.AREA__TIENE:
				getTiene().clear();
				getTiene().addAll((Collection<? extends Empleado>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case InventariosAlmacenesPackage.AREA__ID:
				setId(ID_EDEFAULT);
				return;
			case InventariosAlmacenesPackage.AREA__NOMBRE:
				setNombre(NOMBRE_EDEFAULT);
				return;
			case InventariosAlmacenesPackage.AREA__DESCRIPSION:
				setDescripsion(DESCRIPSION_EDEFAULT);
				return;
			case InventariosAlmacenesPackage.AREA__EREFERENCE0:
				setEReference0((Persona)null);
				return;
			case InventariosAlmacenesPackage.AREA__TIENE:
				getTiene().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case InventariosAlmacenesPackage.AREA__ID:
				return id != ID_EDEFAULT;
			case InventariosAlmacenesPackage.AREA__NOMBRE:
				return NOMBRE_EDEFAULT == null ? nombre != null : !NOMBRE_EDEFAULT.equals(nombre);
			case InventariosAlmacenesPackage.AREA__DESCRIPSION:
				return DESCRIPSION_EDEFAULT == null ? descripsion != null : !DESCRIPSION_EDEFAULT.equals(descripsion);
			case InventariosAlmacenesPackage.AREA__EREFERENCE0:
				return eReference0 != null;
			case InventariosAlmacenesPackage.AREA__TIENE:
				return tiene != null && !tiene.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (id: ");
		result.append(id);
		result.append(", nombre: ");
		result.append(nombre);
		result.append(", descripsion: ");
		result.append(descripsion);
		result.append(')');
		return result.toString();
	}

} //AreaImpl
